<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    span {
        border-bottom: 1px solid black;
        width: 100px;
        display: inline-block;
        text-align: center;
    }

    input {
        outline: 0;
        border: 0;
        border-bottom: 1px solid black;
        width: 100px;
        font-size: 16px;
        text-align: center;
    }
</style>

<body>
    <div id="app">
        <fieldset>
            <legend>edit</legend>
            <p v-for="(v,k,i) in userInfo">
                <label for="">{{k}}</label>
                :
                <input type="text" v-model="val" ref="ipt" @blur="esc(k)" v-if="isEdit&&i===selectedIndex">
                <span @dblclick="edit(v,i)" v-else>{{v}}</span>
            </p>
        </fieldset>
    </div>
</body>

</html>
<script src='https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js'></script>
<script>
    let vm = new Vue({
        el: "#app",
        data: {
            userInfo: {
                "姓名": "马冬梅",
                "年龄": 18,
                "爱好": "夏洛",
                "身高": "150cm"
            },
            val: "夏洛",
            isEdit: false,
            selectedIndex: ""
        },
        methods: {
            edit(v, i) {
                this.isEdit = true
                this.selectedIndex = i
                this.val = v
                this.$nextTick(() => {
                    console.log(this.$refs.ipt[0].focus());
                })
            },
            esc(k) {
                this.isEdit = false
                this.userInfo[k] = this.val
            }
        }
    })
</script>